package com.zhj.rabbitmq.com.controller;

import com.zhj.rabbitmq.com.entity.UserInfo;
import com.zhj.rabbitmq.com.entity.UserInfoVo;
import com.zhj.rabbitmq.com.result.JsonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: rabbimmq-demo
 * @description:
 * @author: zhengjibin
 * @create: 2020-11-24 17:11
 * @Version 1.0
 **/
@RestController
@RequestMapping("/userInfo")
public class UserInfoController {

    @GetMapping("/selectUserList")
    public JsonResult<UserInfoVo> selectUserList(){
        UserInfoVo vo = new UserInfoVo();
        vo.setUserList(new ArrayList<>());
        List<UserInfo> userInfoList = new ArrayList<>();
        userInfoList.add(new UserInfo(1L,"zhangsan"));
        userInfoList.add(new UserInfo(2L,"lisi"));
        vo.getUserList().add(userInfoList);

        List<UserInfo> userInfoList2 = new ArrayList<>();
        userInfoList2.add(new UserInfo(3L,"zhangsan"));
        userInfoList2.add(new UserInfo(4L,"lisi"));
        vo.getUserList().add(userInfoList2);

        vo.setResultList(userInfoList2);
        return JsonResult.success(vo);
    }

    public static void main(String[] args) {
        List<UserInfo> userInfoList = new ArrayList<>();
        userInfoList.add(new UserInfo(1L,"zhangsan"));
        userInfoList.add(new UserInfo(2L,"lisi"));
        List<Long> ids = userInfoList.stream().map(UserInfo :: getId).collect(Collectors.toList());
        System.out.println(ids);
        userInfoList = new ArrayList<>();
        userInfoList.stream().forEach(e -> {
            System.out.println(e.getId());
        });
    }
}
